package com.hyk.controller;

import com.hyk.dto.R;
import com.hyk.model.UserLoginModel;
import com.hyk.service.SysUserLoginService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@Api(tags = "用户登录相关接口")
public class UserLoginController {

    @Resource
    private SysUserLoginService sysUserLoginService;

    @PostMapping("/login")
    @ApiOperation("用户登录接口")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "username", value = "用户名",
                    dataType = "String", defaultValue = "admin"),
            @ApiImplicitParam(name = "password", value = "密码",
                    dataType = "String", defaultValue = "123456")
    })
    public R<UserLoginModel> login(@RequestParam("username") String username,
                                   @RequestParam("password") String password){
        UserLoginModel login = sysUserLoginService.login(username, password);

        //todo 存储redis
        return R.ok(login);
    }

}
